Todo.Model.Item = Backbone.Model.extend({

    // Default attributes for the todo item.
    defaults  : function () {
        return {
            id         : Todo.items ? Todo.items.generateNewId() : _.uniqueId('new_'),
            name       : "Тест",
            completed  : false,
            deleted    : false,
            deadline   : null,
            expired    : false,
            category_id: null,
            position   : Todo.items ? Todo.items.nextOrder() : 1
        };
    },

    // Ensure that each todo created has default fields.
    initialize: function () {
        var name = this.get("name");
        if (!name) {
            this.save({name: this.defaults().title});
        }

        this.on('toggle', this.toggle, this);
    },

    // Toggle the `done` state of this todo item.
    toggle    : function () {
        this.save({completed: !this.get("completed")});

        return this;
    }
});